
import java.io.BufferedReader;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileReader;
import java.io.FileWriter;
import java.io.IOException;

//import com.sun.xml.internal.fastinfoset.algorithm.HexadecimalEncodingAlgorithm;

public class LeitorArquivo {

	String[] args;

	public void lerArquivo(File file){
		FileReader reader;
		BufferedReader bufferedReader;
		File saida=new File("table3.txt");
		int count=1;
		try {
			FileWriter fw = new FileWriter(saida);
			reader = new FileReader(file);
			bufferedReader = new BufferedReader(reader);
			String line= bufferedReader.readLine();
			while(line!=null){
				if(count%9!=0){
					System.out.println(line);
					StringBuffer buffer=new StringBuffer();
					args=line.split(",");

					if(count%9==1)
						buffer.append("int[][] tabuleiro"+count/9+"= {\n");
						
					buffer.append("{ ");
					int i;
					for(i=1;i<=8;i++){
						buffer.append(args[i]);
						buffer.append(",");
					}
					buffer.append(" },");
					
					if(count%9==8)
						buffer.append(" \n };");
						
					fw.write(buffer.toString());
					fw.write("\n");
				}
				line=bufferedReader.readLine();
				count++;
			}
			
			fw.flush();
			fw.close();
	
		} catch (IOException e) {
			e.printStackTrace();
		} 
	}
	
	
	public void geraTestes(){
		File saida=new File("testes.txt");
		try {
			FileWriter fw = new FileWriter(saida);
			int i;
			String s;
//			String borda="borda";
//			String horizontal2="horizontal2";
//			String horizontal3="horizontal3";
//			String horizontal4="horizontal4";
			for (i=0;i<=62;i++){
//				s="teste.imprimeTabuleiro(teste.tabuleiro"+i+");\n" +
//				  "p.setTabuleiro(teste.tabuleiro"+i+");\n"+
//				"System.out.println(p.borda());\n"+
//				"System.out.println(p.horizontal2());\n"+
//				"System.out.println(p.horizontal3());\n"+
//				"System.out.println(p.horizontal4());\n"+
//				"System.out.println(p.diagonal5());\n"+
//				"System.out.println(p.diagonal6());\n"+
//				"System.out.println(p.diagonal7());\n"+
//				"System.out.println(p.mainDiagonal());\n"+
//				"System.out.println(p.edge2x());\n"+
//				"System.out.println(p.corner3x3());\n"+
//				"System.out.println(p.corner2x4());\n"+
//				"System.out.println();\n";	
				
				s="p.setTabuleiro(teste.tabuleiro"+i+");\n"+
				"p.borda();\n"+
				"p.horizontal2();\n"+
				"p.horizontal3();\n"+
				"p.horizontal4();\n"+
				"p.diagonal5();\n"+
				"p.diagonal6();\n"+
				"p.diagonal7();\n"+
				"p.mainDiagonal();\n"+
				"p.edge2x();\n"+
				"p.corner3x3();\n"+
				"p.corner2x4();\n";				
				fw.write(s);
				fw.write("\n");
				
			}
			
			fw.flush();
			fw.close();
	
		} catch (IOException e) {
			e.printStackTrace();
		} 
	}
	
	
	public static void main(String[] args) {
		LeitorArquivo leitor = new LeitorArquivo();
		//leitor.lerArquivo(new File("table2.txt"));
		leitor.geraTestes();
	}

}
